/*
 * Copyright (c) 2024 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */


const DEFAULT_IDENTIFIER = "default";


export class JsonValue {  
    private json: Record<string, any> = {
        _identifier: DEFAULT_IDENTIFIER
    };

    public setIdentifier(identifier: string){
        this.json._identifier = identifier;
    }

    public setLeftOp(leftOp: Record<string, any>){
        this.json.leftOp = leftOp;
    }

    public setRightOp(rightOp: Record<string, any>){
        this.json.rightOp = rightOp;
    }

    public setName(name: string) {
        this.json.name = name;
    }

    public setType(type: Record<string, any>){
        this.json.type = type;
    }

    public setBase(base: string | Record<string, any>){
        this.json.base = base;
    }

    public setIndex(index: number | Record<string, any>){
        this.json.index = index;
    }

    public setValue(value: string){
        this.json.value = value;
    }

    public setArgs(value: Record<string, any>[]) {
        this.json.args = value;
    }

    public setOp(value: Record<string, any>) {
        this.json.op = value;
    }

    public setFunPtrLocal(value: Record<string, any>) {
        this.json.funPtrLocal = value;
    }

    public setClassType(value: Record<string, any>) {
        this.json.classType = value;
    }

    public setBaseType(value: Record<string, any>) {
        this.json.baseType = value;
    }

    public setSize(value: Record<string, any>) {
        this.json.size = value;
    }

    public setField(value: Record<string, any>) {
        this.json.field = value;
    }

    public setPromise(value: Record<string, any>) {
        this.json.promise = value;
    }

    public setYieldValue(value: Record<string, any>) {
        this.json.yieldValue = value;
    }

    public setOp1(value: Record<string, any>) {
        this.json.op1 = value;
    }

    public setOp2(value: Record<string, any>) {
        this.json.op2 = value;
    }

    public setOperator(value: string) {
        this.json.operator = value;
    }

    public setCheckType(value: Record<string, any>) {
        this.json.checkType = value;
    }

    public setLiteralName(value: string | number | boolean) {
        this.json.literalName = value;
    }

    public setTypes(value: Record<string, any>[]) {
        this.json.types = value;
    }

    public setCurrType(value: Record<string, any>) {
        this.json.currType = value;
    }

    public setDimension(value: number) {
        this.json.dimension = value;
    }

    public setOriginalType(value: Record<string, any>) {
        this.json.originalType = value;
    }

    public setOriginType(value: string) {
        this.json.originType = value;
    }

    public setInvokeExpr(value: Record<string, any>) {
        this.json.invokeExpr = value;
    }

    public setConditionExpr(value: Record<string, any>) {
        this.json.conditionExpr = value;
    }

    public setDecorators(value: string[]) {
        this.json.decorators = value;
    }

    public setAny(key: string, value: any){
        this.json[key] = value;
    }

    public merge(json: Record<string, any>){
        this.json = { ...this.json, ...json };
    }

    public getJson(): Record<string, any> {
        return this.json;
    }
}